home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Arashi 1.1.1 / source code / Game Source / Full Arashi Script < prev   
Encoding:
Text File  |  1994-02-24  |  9.8 KB  |  386 lines  |  [TEXT/AR|F]

  1. /*
  2. **    PreScript:
  3. **
  4. **    The prescript normally resides in the Arashi resource fork as resource TEXT 2128. If
  5. **    you modify the actual game source, it is often easier to clear that resource and make
  6. **    modifications to the "Arashi Script" file. Arashi will use a file with that name, if
  7. **    it can be found in the same folder with the application.
  8. **
  9. **    The actual script for the game levels can be found after the prescript and the default
  10. **    game script can be found in TEXT resource 2129. The resource is used only if
  11. **    "Arashi Script" can not be found. (This is unlike TEXT 2128, which is always loaded.)
  12. **
  13. **    Don't remove this comment or type anything before it.
  14. */
  15.  
  16. //    The following variables are for internal use:
  17.  
  18.         DEPTH            =        120
  19.  
  20.         iLevelNumber    =    0
  21.         iLevelField        =    (iLevelNumber + 15) % 16 + 1 min 1 max 16
  22.         iLevelColor        =    ( (iLevelNumber+15) / 16) min 1 max 6 
  23.         iLevelBonus        =    100 * int((iLevelNumber+15) / 16)
  24.         iLevelStartBonus =    500 * int(iLevelNumber^1.5) - 500
  25.         iLevelNext        =    iLevelNumber + 1
  26.  
  27.         iPlayerMaxMove        =    12
  28.         iPlayerSuperZaps    =    1
  29.  
  30.         iShotSpeed        =        4
  31.         iShotPower        =        4
  32.         iShotColor[0]    =        1
  33.         iShotColor[1]    =        0
  34.         iShotColor[2]    =        6
  35.         iShotColor[3]    =        4
  36.         iShotColor[4]    =        5
  37.  
  38.         iFlipperPoints    =        150
  39.         iFlipperCount    =        3
  40.         iFlipperProb    =        700
  41.         iFlipperSpeed    =        65536
  42.         iFlipperRot        =        4
  43.         iFlipperColor    =        2
  44.  
  45.         iTank[0].points    =        100
  46.         iTank[0].count    =        0
  47.         iTank[0].prob    =        600
  48.         iTank[0].speed    =        65536
  49.         iTank[0].color    =        6
  50.  
  51.         iTank[1].points    =        100
  52.         iTank[1].count    =        0
  53.         iTank[1].prob    =        600
  54.         iTank[1].speed    =        65536
  55.         iTank[1].color    =        4
  56.  
  57.         iTank[2].points    =        100
  58.         iTank[2].count    =        0
  59.         iTank[2].prob    =        600
  60.         iTank[2].speed    =        65536
  61.         iTank[2].color    =        0
  62.  
  63.         iFusePoints        =        500
  64.         iFuseBullseye    =        750
  65.         iFuseCount        =        0
  66.         iFuseProb        =        600
  67.         iFuseWarpP        =        2
  68.         iFusePlayerPlus    =        40
  69.         iFuseColor[0]    =        0
  70.         iFuseColor[1]    =        5
  71.         iFuseColor[2]    =        1
  72.         iFuseColor[3]    =        4
  73.         iFuseColor[4]    =        2
  74.  
  75.         iPulsarPoints    =        200
  76.         iPulsarCount    =        0
  77.         iPulsarProb        =        600
  78.         iPulsarSpeed    =        32768
  79.         iPulsarRot        =        5
  80.         iPulsarColor    =        5
  81.         iPulsarTime        =        20
  82.         iPulsarPulsDepth=        DEPTH-DEPTH/5
  83.  
  84.         iSpikerPoints    =        50
  85.         iSpikerProb        =        100
  86.         iSpikerSpeed    =        65536
  87.         iSpikerStart    =        DEPTH
  88.         iSpikerTop        =        10
  89.         iSpikerPlasma    =        1
  90.         iSpikerPlSpeed    =        5*65536
  91.         iSpikerPlPoints    =        200
  92.         iSpikerSpikePoints=        1
  93.         iSpikerColor[0]    =        3
  94.         iSpikerColor[1]    =        0
  95.         iSpikerColor[2]    =        5
  96.  
  97.         iBoredomCount    =        4
  98.         iBoredProb        =        2000
  99.         iEndTimer        =        60
  100.         iAllowPracticeRestart    =        1
  101.         iAllowArcadeRestart        =        1
  102.         iShowSpikesMsg    =    0
  103.         iDoomsday = 0
  104.         
  105. // These are the variables you are supposed to access:
  106.  
  107.     Level            =    iLevelNumber
  108.     SubLevel        =    (Level+15) % 16
  109.     ColorLevel        =    (Level-1) / 16    min 0
  110.     
  111.     iShotPower        =    ShotPower
  112.     ShotPower        =    3
  113.  
  114.     //    Flippers:
  115.     iFlipperProb    =    FlipperProb * 1000 min 0
  116.     iFlipperCount    =    FlipperCount min 0
  117.     iFlipperRot        =    FlipperRot min 0 max 100
  118.     iFlipperSpeed    =    FlipperSpeed * 65536 min 1000
  119.  
  120.     iTank[0].prob    =    FlipTankProb * 1000 min 0
  121.     iTank[0].count    =    FlipTankCount min 0
  122.     iTank[0].speed    =    FlipTankSpeed * 65536 min 1000
  123.  
  124.     //    Spikers:
  125.     iSpikerStart    =    SpikeStart min (DEPTH * 0.05) max DEPTH
  126.     iSpikerTop        =    SpikeTop min (DEPTH * 0.05) max DEPTH
  127.     iSpikerProb        =    (iSpikerTop < DEPTH) * SpikerProb * 100 min 0 max 200
  128.     iSpikerSpeed    =    SpikerSpeed * 65536 min 10000
  129.  
  130.     //    Fuseballs
  131.     iFuseCount        =    FuseCount
  132.     iFuseProb        =    FuseProb * 1000 min 0
  133.     iFuseWarpP        =    FuseWarpP * 10 min 0
  134.     iFusePlayerPlus    =    FusePlayerPlus * 100 min 0
  135.  
  136.     iTank[1].prob    =    FuseTankProb * 1000 min 0
  137.     iTank[1].count    =    FuseTankCount min 0
  138.     iTank[1].speed    =    FuseTankSpeed * 65536 min 1000
  139.  
  140.     //    Pulsars
  141.     iPulsarCount    =    PulsarCount
  142.     iPulsarProb        =    PulsarProb * 1000 min 0
  143.     iPulsarSpeed    =    PulsarSpeed * 65536 min 1000
  144.     iPulsarRot        =    PulsarRot min 0 max 100
  145.     iPulsarTime        =    PulsarTime
  146.  
  147.     iTank[2].prob    =    PulsarTankProb * 1000 min 0
  148.     iTank[2].count    =    PulsarTankCount min 0
  149.     iTank[2].speed    =    PulsarTankSpeed * 65536 min 1000
  150.  
  151.     //    Game difficulty:
  152.     iBoredomCount    =    BoredomCount
  153.     iBoredProb        =    BoredProb * 2000 min 0
  154.     iEndTimer        =    EndTimer * 60 min 1
  155.     iAllowPracticeRestart    =    AllowPracticeRestart - (Level > 95)
  156.     iAllowArcadeRestart    =    AllowArcadeRestart - (Level > 95)
  157.     iShowSpikesMsg    =    (Level > 3) - (Level > 8)
  158.     iDoomsday = (Level > 96)
  159. //    End of prescript.
  160.  
  161.  
  162. /*
  163.     Copyright:
  164.     
  165.         Arashi 1.1
  166.         Copyright ©1993, Project STORM Team
  167.  
  168.         This file is freely distributable,
  169.         but the parser and compiler for
  170.         it may only be used along with the
  171.         Arashi game. For permission to use
  172.         the compiler or parts of it for other
  173.         things, please request permission from
  174.  
  175.                         Juri Munkki
  176.             internet:    jmunkki@hut.fi
  177.             applelink:    sf0010
  178. */
  179.  
  180. FileScript=1    //    Reading from a file. (In case you are interested.)
  181.  
  182. level 1        //    Starting from level 1, use the following rules:
  183.  
  184.     AllowPracticeRestart    =    Level % 2
  185.     AllowArcadeRestart    =    Level % 2
  186.  
  187.     FlipperProb        =    1 + SubLevel / 15
  188.     FlipperCount    =    4 + SubLevel / 3 + Level / 8 - PulsarCount / 3 max 16
  189.     FlipperRot        =    (4 + Level/1.5) ^ 0.7 max 12
  190.     FlipperSpeed    =     (1.0 + Level / 12) ^ 0.3
  191.  
  192.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 3)
  193.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  194.     SpikeTop        =    DEPTH * 0.1
  195.     SpikerSpeed        =    1 + Level / 40 max 2.5
  196.     
  197.     EndTimer        =    3.2 / Level max 1.5
  198.     BoredomCount    =    2 + Level / 10 max 7
  199.     BoredProb        =    1.0 + Level / 32
  200.  
  201.     FlipTankCount    =    (SubLevel - 1) ^ 0.7 - FuseTankCount / 2
  202.     FlipTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  203.     FlipTankProb    =    0.3 + SubLevel / 20
  204.     
  205. level 11
  206.     FuseCount        =    2
  207.     FuseProb        =    0.5 + SubLevel / 15
  208.     FuseWarpP        =    Level / 100 max 0.5
  209.     FusePlayerPlus    =    Level / 40 max 0.9
  210.     
  211. level 16
  212.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  213.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 1)
  214.     
  215. level 17
  216.     FuseCount        =    0
  217.     PulsarProb        =    0.7 + SubLevel / 20
  218.     PulsarCount        =    4 + SubLevel / 5 + Level / 10 max 12
  219.     PulsarRot        =    (4 + Level/2) ^ 0.6 max 11
  220.     PulsarSpeed        =    (Level / 20) ^ 0.3
  221.     PulsarTime        =    20 - Level / 20 min 5
  222.  
  223. level 19
  224.     FuseCount        =    (Level / 3) ^ 0.7 max 6
  225.     AllowArcadeRestart    =    (Level % 2) < 1
  226.  
  227. level 30
  228.     AllowArcadeRestart    =    (Level % 2)
  229.     
  230. level 33
  231.     FuseTankCount    =    SubLevel ^ 0.3 + 2 - PulsarTankCount / 2
  232.     FuseTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  233.     FuseTankProb    =    0.3 + SubLevel / 20
  234.  
  235. level 35
  236.     AllowArcadeRestart    =    (Level % 4) < 1
  237.     
  238. level 40
  239.     PulsarTankCount    =    SubLevel ^ 0.3 + 2
  240.     PulsarTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  241.     PulsarTankProb    =    0.3 + SubLevel / 20
  242.  
  243. level 47
  244.     AllowArcadeRestart    =    (Level % 2)
  245.  
  246. level 51
  247.     AllowArcadeRestart    =    (Level % 4) < 1
  248.     
  249. level 63
  250.     AllowArcadeRestart    =    (Level % 2)
  251.     
  252. level 67
  253.     AllowArcadeRestart    =    ((Level-65) % 8) < 1
  254.     
  255. level 82
  256.     AllowArcadeRestart    =    0
  257.     
  258.     
  259. level 32000    //    We should never need to go past this point
  260.  
  261. /* Finally, some instructions on how to modify this file:
  262.  
  263.  
  264. Here's a short grammar of the language. It should be pretty obvious for anyone
  265. with a little background in grammars.
  266.  
  267. Items in braces can be repeated 
  268.  
  269. statement    ->    level n
  270.                 variable = compare
  271.  
  272. compare        ->    minmax { = minmax }
  273.                 minmax { > minmax }
  274.                 minmax { < minmax }
  275.  
  276. minmax        ->    expr { min expr }
  277.                 expr { max expr }
  278.  
  279. expr        ->    term { + term }
  280.                 term { - term }
  281.  
  282. term        ->    power { * power }
  283.                 power { / power }
  284.                 power { % power }
  285.  
  286. power        ->    factor { ^ factor }
  287.  
  288. factor        ->    (compare)
  289.                 -factor
  290.                 factor
  291.                 +factor
  292.                 variable
  293.                 constant
  294.                 function1 factor
  295.                 function0
  296.  
  297.  
  298. functions with no parameters: (function0)
  299.  
  300.         random
  301.  
  302. functions with one parameter: (function1)
  303.  
  304.         |         (abs)
  305.         sin
  306.         cos
  307.         int
  308.         round
  309.  
  310. keywords:
  311.         level
  312.  
  313.  
  314.     *********************
  315.     *    How it works    *
  316.     *********************
  317.  
  318. The idea is that you define variables and that new lines in
  319. the script will replace old lines. For a certain level, only
  320. those definitions that appear before the next greater 'level'
  321. statement will be used to define that level.
  322.  
  323. Order of evaluation is unspecified and there are no guarantees
  324. that variables will have reasonable values unless they are
  325. initialized. If a circular reference is encountered, an old
  326. value of a looped variable will be used to get out of the loop.
  327.  
  328. For instance:
  329.  
  330.     a = b
  331.     b = a + 1
  332.     
  333. If we evaluate a, we usually get 1 on the first round. This is
  334. because most variables are initialized to 0. If we execute it
  335. again, we get 2 etc. If, instead we evaluate b, we get 1, but
  336. the value of a will be 0. I hope this is confusing enough so
  337. that you will avoid circular references. Let's just say that
  338. they are not very useful, but they do not cause problems.
  339.  
  340. The order of evaluation is on a "need to know basis". I guess
  341. it's called intelligent recalculation in spreadsheet programs.
  342. Let's look at it with a short example:
  343.  
  344.     a = 10
  345.     b = a + 20
  346.     c = 30
  347.     d = b + a
  348.     
  349. If we then evaluate d, the system will try to evaluate b, notice
  350. that b requires a to be defined, so it evaluates a and then b. It
  351. then sees a again, but notices that it has been evaluated already
  352. and uses the old value. c does not get evaluated at all.
  353.  
  354. Let's look at something more complicated:
  355.  
  356.     level 1
  357.     
  358.         b = a
  359.         a = 1
  360.         a = 2
  361.  
  362.     level 16
  363.     
  364.         a = 3
  365.  
  366. From levels 1 to 15, b will evaluate to 2, because that's the last
  367. definition of a. From level 16, the value of b will be 3.
  368.  
  369. The definition a = 1 is not used at all, although it does get compiled
  370. before the next line replaces it.
  371.  
  372. To actually define a game level, you have to define variables that of
  373. interest to the game. These variables are introduced in a prescript
  374. resource. Feel free to peek at that resource to see what variables are
  375. available [during development, the prescript might be empty and the
  376. Arashi Script file could contain everything].
  377.  
  378. Variables that are prefixed with an 'i' are by convention internal
  379. variables. In the next part of the prescript, these variables are
  380. connected with variables that you should use. For instance, we have
  381. iFlipperCount and FlipperCount. You should use FlipperCount even though
  382. iFlipperCount is really the variable that the game wants. This convention
  383. allows us to scale or limit the values that can be set. For instance,
  384. we should probably limit FlipperCount to a minimum of 0.
  385.  
  386. */